package com.souku.finance.application.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

import com.souku.finance.application.R;

/**
 * Created by Android on 2016/12/22.
 */

public class PointView extends View {

    //设定颜色
    private int mainColor = getResources().getColor(R.color.main);

    private Paint mPaint;

    public PointView(Context context) {
        super(context);
    }

    public PointView(Context context, AttributeSet attrs) {
        super(context, attrs);

        // 获得自定义属性，tab的数量
        TypedArray a = context.obtainStyledAttributes(attrs,
                R.styleable.ViewPoint);
        mainColor = a.getColor(R.styleable.ViewPoint_item_color,
                getResources().getColor(R.color.main));
        a.recycle();
        // 初始化画笔
        mPaint = new Paint();
        mPaint.setAntiAlias(true);
        mPaint.setColor(mainColor);
        mPaint.setStyle(Paint.Style.FILL);
    }

    public PointView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        int size = getWidth();
        canvas.drawCircle(size / 2, size / 2, size / 2, mPaint);
    }
}
